package com.steak.concurrent.objects;

import lombok.SneakyThrows;

public class ObjectMethodTest {
    public static void main(String[] args) {
        Object o = new Object();
        //线程1
        new Thread(new Runnable() {
            @SneakyThrows
            @Override
            public void run() {
                synchronized (o) {
                    o.wait();
                }
                System.out.println("thread-1");
            }
        }).start();
        //线程2
        new Thread(new Runnable() {
            @SneakyThrows
            @Override
            public void run() {
                synchronized (o) {
                    o.wait();
                }
                System.out.println("thread-2");
            }
        }).start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                synchronized (o){
                    o.notifyAll();
                }
            }
        }).start();
    }
}
